home *** CD-ROM | disk | FTP | other *** search
- Path: binah.cc.brandeis.edu!DERNIS
- From: dernis@binah.cc.brandeis.edu
- Newsgroups: comp.lang.ada,comp.lang.c,comp.lang.c++
- Subject: Re: C/C++ knocks the crap out of Ada
- Date: 11 Mar 1996 02:01:15 GMT
- Organization: Brandeis University
- Message-ID: <4i01hb$s6j@new-news.cc.brandeis.edu>
- References: <00001a73+00002504@msn.com> <1996Feb22.005518.13396@leeweyr.sccsi.com> <4gvrffINNlqo@anvil.ugrad.cs.ubc.ca> <4h5hgj$vpd@tomquartz.niestu.com> <4h7jskINNnph@anvil.ugrad.cs.ubc.ca> <313EDF38.61C1@lfwc.lockheed.com> <TANMOY.96Mar7180321@qcd.lanl.gov>
- Reply-To: dernis@binah.cc.brandeis.edu
- NNTP-Posting-Host: binah.cc.brandeis.edu
-
- Sorry I lost the credit:
- >
- >To be precise, C standard declares all programs that violate array
- >bounds as illegal, but does not _require_ the compiler to check for
- >these violations. This is a change from pre-standard days when a
- >program was considered valid as long as it did not try to access
- >memory beyond what was allocated to it.
- >
- >As an example,
- >
- >char a2[100][100];
- >char *a = &a2[0][0];
- >
- >It is obvious from the constraints of memory layout for arrays and
- >pointer arithmetic, that a+200 would have pointed to a[2][0] if it
- >were valid. However, the standard has declared a+200 to invoke
- >undefined behaviour. Thus, a very strict bounds checking
- >implementation can reject such pointer arithmetic without violating
- >the standard.
-
- It does little good to tell a programmer not to do
- something in the language standard when I bet most
- programmers have never read the ARM, and certainly
- do not keep up with the latest version.
-
-
- I have jus read a good deal of this thread. Several people
- have made this argument to me that many languages not just
- ADA impose more (better?) structure, on the programmer. Thus
- resulting in better reliability. It is also readily agreed that
- this is done at some expense in terms of memory requirments,
- and also speed (especially in tight loops).
-
- I went from the evolution from C to C++, and feel that many
- of these problems can be easily solved if programmers just
- took advantage of the new features. C++ can be safer. For
- example, if you write (or buy) a good array class and use it
- instead of the standard types, then you will know longer have
- run away arrays. Additionally, you can perform range checking
- or anything else. For that matter, a heap class can be defined
- to handle garbage collection as well. Some have set let's compare
- languages as they are. I recall when I read Lipmann's book
- that much of the addition of C++ was so that encapsulation could
- save the world from sloppy code. So it is *fair* in my mind
- to say that on large projects which are inherently difficult to
- debug, bound checking class be used de rigor. However, in a tight loop
- you are free to use the standard types with no range or bounds
- checking. Just be damn sure it is contained in a small block
- of code and that you don't screw it up.
-
- It would seem to me
- that any language which incorporates range checking, bound
- checking, garbage collection, etc. from the get go loses the
- flexibility of higher performance in critical areas. This may
- not be a problem for most projects since memory has become
- so cheap and computers so fast, but many people, particularly
- poor graduate students like me, would like their current
- hardrives and CPU RAM to hold out for a while.
-
- I am always a few months/years behind on standards. Are there
- standard container classes? I think the standard "c" libraries,
- streams, and complex libraries, are not nearly enough. Well
- implimented standard libraries for safer programming seems like
- a logical direction of evolution.
-
- Mitch Dernis
-